02 / 17

What is the role of the <label> tag in forms ?

The <label> tag in HTML is used to define a label for form elements like <input>, <textarea>, and <select>. It improves accessibility and usability by making forms easier to understand and interact with. When a label is clicked, it automatically focuses or activates the associated form element.

Key Points About <label>
  1. 1

    It describes the purpose of a form element.

  2. 2

    The 'for' attribute links the label to a specific input by matching the input's 'id'.

  3. 3

    Clicking the label focuses the corresponding input, improving user experience.

  4. 4

    It is especially important for screen readers, enhancing accessibility.

Example of <label> Usage